package com.lee.study.ws.config;

import com.lee.study.ws.websocket.MyHanler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

/**
 * WebSocket 使用SocketJS
 * Created by alex on 15-1-13.
 */
public class WebSocketWithSockJSConfig implements WebSocketConfigurer {
    
    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(myHandler(),"/myHandler").withSockJS();
    }
    
    @Bean
    public WebSocketHandler myHandler(){
        return new MyHanler();
    }
}
